#pragma once
#ifndef __HASH_H__
#define __HASH_H__

#include "CString.h"
extern "C" {
#include "openssl/err.h"
#include "openssl/evp.h"
#include "openssl/ec.h"
#include <openssl/pem.h>
#include <openssl/rand.h>
}

#define HASH_MODE_MAX   (16)
#define RNG_BLOCK_LEN   (16)

typedef const EVP_MD* (*EVP_MD_FUNC)(void);
typedef enum {
    SM3,
    SHA_1,
    SHA_224,
    SHA_256,
    SHA_384,
    SHA_512,
    SHA_512_224,
    SHA_512_256,
    SHA3_224,
    SHA3_256,
    SHA3_384,
    SHA3_512,
    SHAKE_128,
    SHAKE_256,
    MD5,
    MD5_sha1
}HASH_TYPE;

class HASH
{
public:
    HASH();
    ~HASH();

    CString Hash(CString data, HASH_TYPE mode);

private:
    EVP_MD_CTX* ctx_hash = NULL;
    EVP_MD_FUNC hash_fun[HASH_MODE_MAX] = { EVP_sm3 ,
                                            EVP_sha1 ,
                                            EVP_sha224 ,
                                            EVP_sha256 ,
                                            EVP_sha384 ,
                                            EVP_sha512 ,
                                            EVP_sha512_224 ,
                                            EVP_sha512_256 ,
                                            EVP_sha3_224 ,
                                            EVP_sha3_256 ,
                                            EVP_sha3_384 ,
                                            EVP_sha3_512 ,
                                            EVP_shake128 ,
                                            EVP_shake256 , 
                                            EVP_md5 , 
                                            EVP_md5_sha1
                                          };

};


#endif // !__HASH_H__



